package com.wu.llpsw.item.wushu;

import com.wu.llpsw.effect.buff.yehuoduanti;
import com.wu.llpsw.networking.ModMessage;
import com.wu.llpsw.networking.packet.backYuanLiMaxPacket;
import com.wu.llpsw.networking.packet.backYuanLiNowPacket;
import com.wu.llpsw.yuanli.energy.yuanliManager;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResultHolder;
import net.minecraft.world.effect.MobEffectCategory;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.Level;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.List;

public class yehuoduantiItem extends Item {
    private int setup=50;
    public yehuoduantiItem(Properties p_41383_) {
        super(p_41383_);
    }


    @NotNull
    @Override
    public InteractionResultHolder<ItemStack> use(@NotNull Level world, @NotNull Player player, @NotNull InteractionHand hand) {
        if (!world.isClientSide) {

            if(yuanliManager.getNowYuanLi(player)>=setup){
                yuanliManager.use(player,-setup);

                //给予业火锻体buff
                player.addEffect(new MobEffectInstance(new yehuoduanti(MobEffectCategory.HARMFUL, 0x000033, false), 20*6, 1));

                player.getCooldowns().addCooldown(this,20*4);
            }
        }
        return InteractionResultHolder.success(player.getItemInHand(hand));
    }

    //添加描述
    @Override
    public void appendHoverText(ItemStack p_41421_, @Nullable Level p_41422_, List<Component> p_41423_, TooltipFlag p_41424_) {
        p_41423_.add(new TranslatableComponent("tooltip.wu.yehuoduanti.tooltip"));
    }
}
